package com.kclm.se.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class SimpleClient {

	public static void main(String[] args){
		//
		final String host = "127.0.0.1";
		final int port = 10080;
		//
		try {
			Socket c = new Socket(host, port);
			//
			System.out.println("连接已经建立...");
			// read and write
			try(BufferedReader br = 
					new BufferedReader(
							new InputStreamReader(c.getInputStream()));
					PrintWriter out = new PrintWriter(c.getOutputStream(),true)) {
				//
				out.println("send by client: hello");
				//
				System.out.println(br.readLine());
			}
			c.close();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}
